//
//  DCFAlertView.m
//  DCF
//
//  Created by 吴文拼 on 2017/12/26.
//  Copyright © 2017年 吴文拼. All rights reserved.
//

#import "DCFAlertView.h"
#import "DCFNormalView.h"
#import "DCFCommonUtils.h"

@interface DCFAlertView()

@property (nonatomic , strong)DCFNormalView *centerView;

@property (nonatomic , strong)DCFNormalImageView *titleImV;

@property (nonatomic , strong)DCFNormalLabel *headerLab;

@property (nonatomic , strong)DCFNormalLabel *detailLab;

@property (nonatomic , strong)DCFNormalLabel *leftBtn;

@property (nonatomic , strong)DCFNormalLabel *rightBtn;

@property (nonatomic , strong)DCFNormalLabel *bottomBtn;

@end

@implementation DCFAlertView

-(instancetype)initWithDelegate:(id)delegate withTitleText:(NSString *)titleText andDetailText:(NSString *)detailText andBottomBtnTitleArr:(nonnull NSArray<NSString *> *)btnTitleArr{
    if (self = [super init]) {
        self.delegate = delegate;
        self.frame = [UIScreen mainScreen].bounds;
        self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4f];
        CGFloat height = [DCFCommonUtils string:detailText size:CGSizeMake(252, CGFLOAT_MAX) fontSize:15.0f].height+5;
        CGFloat normalHeight = 126;
        if (!titleText) {
            normalHeight = 91;
        }
        [self addSubview:self.centerView];
        [_centerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self);
            make.width.equalTo(@300);
            make.height.equalTo(@(height+normalHeight));
        }];
        if (titleText) {
            [_centerView addSubview:self.headerLab];
            self.headerLab.text = titleText;
            [_headerLab mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(_centerView).offset(28);
                make.centerX.equalTo(_centerView);
                make.size.equalTo([NSValue valueWithCGSize:CGSizeMake(252, 25)]);
            }];
        }
        [_centerView addSubview:self.detailLab];
        _detailLab.text = detailText;
        [_detailLab mas_makeConstraints:^(MASConstraintMaker *make) {
            if (titleText) {
                make.top.equalTo(_headerLab.mas_bottom).offset(10);
            }else{
                make.top.equalTo(_centerView).offset(28);
            }
            make.centerX.equalTo(_centerView);
            make.size.equalTo([NSValue valueWithCGSize:CGSizeMake(252, height)]);
        }];
        DCFNormalView *lineV = [[DCFNormalView alloc] init];
        [lineV setBackgroundColor:RGBCOLOR(236, 236, 236)];
        [_centerView addSubview:lineV];
        [lineV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(_centerView.mas_bottom).offset(-49);
            make.centerX.equalTo(_centerView);
            make.width.equalTo(_centerView);
            make.height.equalTo(@1);
        }];
        
        if (btnTitleArr.count == 2) {
            [_centerView addSubview:self.leftBtn];
            _leftBtn.text = btnTitleArr[0];
            [_leftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(_centerView);
                make.bottom.equalTo(_centerView);
                make.top.equalTo(lineV.mas_bottom);
                make.right.equalTo(_centerView.mas_centerX);
            }];
            [_centerView addSubview:self.rightBtn];
            _rightBtn.text = btnTitleArr[1];
            [_rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(_centerView);
                make.bottom.equalTo(_centerView);
                make.top.equalTo(lineV.mas_bottom);
                make.left.equalTo(_centerView.mas_centerX);
            }];
            DCFNormalView *lineV2 = [[DCFNormalView alloc] init];
            [lineV2 setBackgroundColor:RGBCOLOR(236, 236, 236)];
            [_centerView addSubview:lineV2];
            [lineV2 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(lineV.mas_bottom);
                make.centerX.equalTo(_centerView);
                make.width.equalTo(@1);
                make.bottom.equalTo(_centerView);
            }];
        }else{
            [_centerView addSubview:self.bottomBtn];
            _bottomBtn.text = btnTitleArr[0];
            [_bottomBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(_centerView);
                make.bottom.equalTo(_centerView);
                make.top.equalTo(lineV.mas_bottom);
                make.right.equalTo(_centerView);
            }];
        }
    }
    return self;
}

-(instancetype)initLongTextWithDelegate:(id)delegate withTitleText:(NSString *)titleText andDetailText:(NSString *)detailText andBottomBtnTitleArr:(nonnull NSArray<NSString *> *)btnTitleArr{
    if (self = [super init]) {
        self.delegate = delegate;
        self.frame = [UIScreen mainScreen].bounds;
        self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4f];
        CGFloat height = 300;
        CGFloat normalHeight = 126;
        if (!titleText) {
            normalHeight = 91;
        }
        [self addSubview:self.centerView];
        [_centerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self);
            make.width.equalTo(@300);
            make.height.equalTo(@(height+normalHeight));
        }];
        if (titleText) {
            [_centerView addSubview:self.headerLab];
            self.headerLab.text = titleText;
            [_headerLab mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(_centerView).offset(28);
                make.centerX.equalTo(_centerView);
                make.size.equalTo([NSValue valueWithCGSize:CGSizeMake(252, 25)]);
            }];
        }
        UITextView *textView = [[UITextView alloc] init];
        textView.editable = NO;
        textView.backgroundColor = [UIColor whiteColor];
        [textView setFont:[UIFont systemFontOfSize:15.0f]];
        [textView setTextColor:RGBCOLOR(102, 102, 102)];
        [_centerView addSubview:textView];
        textView.text = detailText;
        [textView mas_makeConstraints:^(MASConstraintMaker *make) {
            if (titleText) {
                make.top.equalTo(_headerLab.mas_bottom).offset(10);
            }else{
                make.top.equalTo(_centerView).offset(28);
            }
            make.centerX.equalTo(_centerView);
            make.size.equalTo([NSValue valueWithCGSize:CGSizeMake(252, height)]);
        }];
        DCFNormalView *lineV = [[DCFNormalView alloc] init];
        [lineV setBackgroundColor:RGBCOLOR(236, 236, 236)];
        [_centerView addSubview:lineV];
        [lineV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(_centerView.mas_bottom).offset(-49);
            make.centerX.equalTo(_centerView);
            make.width.equalTo(_centerView);
            make.height.equalTo(@1);
        }];
        
        if (btnTitleArr.count == 2) {
            [_centerView addSubview:self.leftBtn];
            _leftBtn.text = btnTitleArr[0];
            [_leftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(_centerView);
                make.bottom.equalTo(_centerView);
                make.top.equalTo(lineV.mas_bottom);
                make.right.equalTo(_centerView.mas_centerX);
            }];
            [_centerView addSubview:self.rightBtn];
            _rightBtn.text = btnTitleArr[1];
            [_rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(_centerView);
                make.bottom.equalTo(_centerView);
                make.top.equalTo(lineV.mas_bottom);
                make.left.equalTo(_centerView.mas_centerX);
            }];
            DCFNormalView *lineV2 = [[DCFNormalView alloc] init];
            [lineV2 setBackgroundColor:RGBCOLOR(236, 236, 236)];
            [_centerView addSubview:lineV2];
            [lineV2 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(lineV.mas_bottom);
                make.centerX.equalTo(_centerView);
                make.width.equalTo(@1);
                make.bottom.equalTo(_centerView);
            }];
        }else{
            [_centerView addSubview:self.bottomBtn];
            _bottomBtn.text = btnTitleArr[0];
            [_bottomBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(_centerView);
                make.bottom.equalTo(_centerView);
                make.top.equalTo(lineV.mas_bottom);
                make.right.equalTo(_centerView);
            }];
        }
    }
    return self;
}

-(instancetype)initWithDelegate:(id)delegate titleImage:(UIImage *)titleImage imageSize:(CGSize)imageSize withTitleText:(NSString *)titleText andDetailText:(NSString *)detailText andBottomBtnTitleArr:(NSArray<NSString *> *)btnTitleArr{
    if (self = [super init]) {
        self.delegate = delegate;
        self.frame = [UIScreen mainScreen].bounds;
        self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4f];
        CGFloat height = [DCFCommonUtils string:detailText size:CGSizeMake(252, CGFLOAT_MAX) fontSize:15.0f].height+5;
        CGFloat normalHeight = 143 + imageSize.height;
        if (!titleText) {
            normalHeight = 108 + imageSize.height;
        }
        [self addSubview:self.centerView];
        [_centerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self);
            make.width.equalTo(@300);
            make.height.equalTo(@(height+normalHeight));
        }];
        [_centerView addSubview:self.titleImV];
        [_titleImV set_dcf_image:titleImage];
        [_titleImV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(_centerView);
            make.top.equalTo(_centerView).offset(28);
            make.size.equalTo([NSValue valueWithCGSize:imageSize]);
        }];
        if (titleText) {
            [_centerView addSubview:self.headerLab];
            self.headerLab.text = titleText;
            [_headerLab mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(_titleImV.mas_bottom).offset(18);
                make.centerX.equalTo(_centerView);
                make.size.equalTo([NSValue valueWithCGSize:CGSizeMake(252, 25)]);
            }];
        }
        [_centerView addSubview:self.detailLab];
        _detailLab.text = detailText;
        [_detailLab mas_makeConstraints:^(MASConstraintMaker *make) {
            if (titleText) {
                make.top.equalTo(_headerLab.mas_bottom).offset(10);
            }else{
                make.top.equalTo(_titleImV.mas_bottom).offset(18);
            }
            make.centerX.equalTo(_centerView);
            make.size.equalTo([NSValue valueWithCGSize:CGSizeMake(252, height)]);
        }];
        DCFNormalView *lineV = [[DCFNormalView alloc] init];
        [lineV setBackgroundColor:RGBCOLOR(236, 236, 236)];
        [_centerView addSubview:lineV];
        [lineV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(_centerView.mas_bottom).offset(-49);
            make.centerX.equalTo(_centerView);
            make.width.equalTo(_centerView);
            make.height.equalTo(@1);
        }];
        
        if (btnTitleArr.count == 2) {
            [_centerView addSubview:self.leftBtn];
            _leftBtn.text = btnTitleArr[0];
            [_leftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(_centerView);
                make.bottom.equalTo(_centerView);
                make.top.equalTo(lineV.mas_bottom);
                make.right.equalTo(_centerView.mas_centerX);
            }];
            [_centerView addSubview:self.rightBtn];
            _rightBtn.text = btnTitleArr[1];
            [_rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(_centerView);
                make.bottom.equalTo(_centerView);
                make.top.equalTo(lineV.mas_bottom);
                make.left.equalTo(_centerView.mas_centerX);
            }];
            DCFNormalView *lineV2 = [[DCFNormalView alloc] init];
            [lineV2 setBackgroundColor:RGBCOLOR(236, 236, 236)];
            [_centerView addSubview:lineV2];
            [lineV2 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(lineV.mas_bottom);
                make.centerX.equalTo(_centerView);
                make.width.equalTo(@1);
                make.bottom.equalTo(_centerView);
            }];
        }else{
            [_centerView addSubview:self.bottomBtn];
            _bottomBtn.text = btnTitleArr[0];
            [_bottomBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(_centerView);
                make.bottom.equalTo(_centerView);
                make.top.equalTo(lineV.mas_bottom);
                make.right.equalTo(_centerView);
            }];
        }
    }
    return self;
}

-(instancetype)initInScanFaceWithDelegate:(id)delegate andBackImg:(UIImage *)backImg{
    if (self = [super init]) {
        self.delegate = delegate;
        self.frame = [UIScreen mainScreen].bounds;
        DCFNormalImageView *backImV = [[DCFNormalImageView alloc] init];
        [backImV set_dcf_image:backImg];
        [self addSubview:backImV];
        [backImV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self);
            make.size.equalTo(self);
        }];
        UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
        UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:effect];
        effectView.frame = CGRectMake(0, 0, backImV.frame.size.width, backImV.frame.size.height);
        effectView.alpha = 0.5f;
        [backImV addSubview:effectView];
        DCFNormalView *backV = [[DCFNormalView alloc] init];
        [backV set_dcf_backgroundColor:[UIColor colorWithWhite:0 alpha:0.6f]];
        [self addSubview:backV];
        [backV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self);
            make.size.equalTo(self);
        }];
        DCFNormalView *centerView = [[DCFNormalView alloc] init];
        [centerView set_dcf_layerCornerRadius:5.0f];
        [centerView set_dcf_layerBackgroundColor:[UIColor whiteColor]];
        [self addSubview:centerView];
        [centerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self);
            make.size.equalTo([NSValue valueWithCGSize:CGSizeMake(300, 368)]);
        }];
        DCFNormalLabel *titleLab = [[DCFNormalLabel alloc] init];
        [titleLab set_dcf_font:[UIFont systemFontOfSize:15.0f]];
        [titleLab set_dcf_textAligment:NSTextAlignmentCenter];
        [titleLab set_dcf_textColor:RGBCOLOR(102, 102, 102)];
        titleLab.numberOfLines = 0;
        titleLab.text = @"请将头像至于取景框内并按提示操作";
        [centerView addSubview:titleLab];
        [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(centerView);
            make.top.equalTo(centerView).offset(21);
            make.size.equalTo([NSValue valueWithCGSize:CGSizeMake(200, 48)]);
        }];
        DCFNormalImageView *imV1 = [[DCFNormalImageView alloc] init];
        [imV1 set_dcf_image:[UIImage imageNamed:@"scanface_alert_image_1"]];
        [centerView addSubview:imV1];
        [imV1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(centerView);
            make.top.equalTo(titleLab.mas_bottom).offset(13);
            make.size.equalTo([NSValue valueWithCGSize:CGSizeMake(91, 80)]);
        }];
        DCFNormalLabel *lab1 = [[DCFNormalLabel alloc] init];
        [lab1 set_dcf_textAligment:NSTextAlignmentCenter];
        [lab1 set_dcf_textColor:RGBCOLOR(102, 102, 102)];
        [lab1 set_dcf_font:[UIFont systemFontOfSize:12]];
        lab1.text = @"正确的姿势";
        [centerView addSubview:lab1];
        [lab1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(imV1);
            make.top.equalTo(imV1.mas_bottom).offset(8);
            make.size.equalTo([NSValue valueWithCGSize:CGSizeMake(64, 17)]);
        }];
        DCFNormalImageView *imV2 = [[DCFNormalImageView alloc] init];
        [imV2 set_dcf_image:[UIImage imageNamed:@"scanface_alert_image_2"]];
        [centerView addSubview:imV2];
        [imV2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(centerView);
            make.top.equalTo(imV1.mas_bottom).offset(38);
            make.size.equalTo([NSValue valueWithCGSize:CGSizeMake(69, 63)]);
        }];
        DCFNormalLabel *lab2 = [[DCFNormalLabel alloc] init];
        [lab2 set_dcf_textAligment:NSTextAlignmentCenter];
        [lab2 set_dcf_textColor:RGBCOLOR(102, 102, 102)];
        [lab2 set_dcf_font:[UIFont systemFontOfSize:12]];
        lab2.text = @"过远";
        [centerView addSubview:lab2];
        [lab2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(imV2);
            make.top.equalTo(imV2.mas_bottom).offset(8);
            make.size.equalTo([NSValue valueWithCGSize:CGSizeMake(64, 17)]);
        }];
        DCFNormalImageView *imV3 = [[DCFNormalImageView alloc] init];
        [imV3 set_dcf_image:[UIImage imageNamed:@"scanface_alert_image_3"]];
        [centerView addSubview:imV3];
        [imV3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(imV2);
            make.right.equalTo(imV2.mas_left).offset(-10);
            make.size.equalTo([NSValue valueWithCGSize:CGSizeMake(69, 63)]);
        }];
        DCFNormalLabel *lab3 = [[DCFNormalLabel alloc] init];
        [lab3 set_dcf_textAligment:NSTextAlignmentCenter];
        [lab3 set_dcf_textColor:RGBCOLOR(102, 102, 102)];
        [lab3 set_dcf_font:[UIFont systemFontOfSize:12]];
        lab3.text = @"过近";
        [centerView addSubview:lab3];
        [lab3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(imV3);
            make.top.equalTo(imV3.mas_bottom).offset(8);
            make.size.equalTo([NSValue valueWithCGSize:CGSizeMake(64, 17)]);
        }];
        DCFNormalImageView *imV4 = [[DCFNormalImageView alloc] init];
        [imV4 set_dcf_image:[UIImage imageNamed:@"scanface_alert_image_4"]];
        [centerView addSubview:imV4];
        [imV4 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(imV2);
            make.left.equalTo(imV2.mas_right).offset(10);
            make.size.equalTo([NSValue valueWithCGSize:CGSizeMake(69, 63)]);
        }];
        DCFNormalLabel *lab4 = [[DCFNormalLabel alloc] init];
        [lab4 set_dcf_textAligment:NSTextAlignmentCenter];
        [lab4 set_dcf_textColor:RGBCOLOR(102, 102, 102)];
        [lab4 set_dcf_font:[UIFont systemFontOfSize:12]];
        lab4.text = @"光线太暗";
        [centerView addSubview:lab4];
        [lab4 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(imV4);
            make.top.equalTo(imV4.mas_bottom).offset(8);
            make.size.equalTo([NSValue valueWithCGSize:CGSizeMake(64, 17)]);
        }];
        DCFNormalLabel *bottomBtn = [[DCFNormalLabel alloc] init];
        [bottomBtn set_dcf_textAligment:NSTextAlignmentCenter];
        [bottomBtn set_dcf_font:[UIFont systemFontOfSize:18.0f]];
        [bottomBtn set_dcf_textColor:[UIColor whiteColor]];
        [bottomBtn set_dcf_layerCornerRadius:5.0f];
        [bottomBtn set_dcf_layerBackgroundColor:kMainColor];
        bottomBtn.text = @"我知道了";
        bottomBtn.userInteractionEnabled = YES;
        [bottomBtn addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickBtn)]];
        [centerView addSubview:bottomBtn];
        [bottomBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(centerView);
            make.bottom.equalTo(centerView).offset(-24);
            make.size.equalTo([NSValue valueWithCGSize:CGSizeMake(209, 43)]);
        }];
    }
    return self;
}

-(void)clickBtn{
    [self hide];
    if (_delegate && [_delegate respondsToSelector:@selector(dcfAlertView:withButtonIndex:)]) {
        [_delegate dcfAlertView:self withButtonIndex:0];
    }
}


-(void)showInView:(UIView *)view{
    [view addSubview:self];
}

-(void)hide{
    [self removeFromSuperview];
}

-(DCFNormalView *)centerView{
    if (!_centerView) {
        _centerView = [[DCFNormalView alloc] init];
        [_centerView set_dcf_layerCornerRadius:5.0f];
        [_centerView set_dcf_layerBackgroundColor:[UIColor whiteColor]];
        _centerView.clipsToBounds = YES;
    }
    return _centerView;
}

-(DCFNormalImageView *)titleImV{
    if (!_titleImV) {
        _titleImV = [[DCFNormalImageView alloc] init];
    }
    return _titleImV;
}

-(DCFNormalLabel *)headerLab{
    if (!_headerLab) {
        _headerLab = [[DCFNormalLabel alloc] init];
        [_headerLab set_dcf_textAligment:NSTextAlignmentCenter];
        [_headerLab set_dcf_font:[UIFont systemFontOfSize:18.0f]];
        [_headerLab set_dcf_textColor:RGBCOLOR(51, 51, 51)];
    }
    return _headerLab;
}

-(DCFNormalLabel *)detailLab{
    if (!_detailLab) {
        _detailLab = [[DCFNormalLabel alloc] init];
        [_detailLab set_dcf_textAligment:NSTextAlignmentCenter];
        [_detailLab set_dcf_font:[UIFont systemFontOfSize:15.0f]];
        [_detailLab set_dcf_textColor:RGBCOLOR(102, 102, 102)];
        _detailLab.numberOfLines = 0;
    }
    return _detailLab;
}

-(DCFNormalLabel *)leftBtn{
    if (!_leftBtn) {
        _leftBtn = [[DCFNormalLabel alloc] init];
        _leftBtn.userInteractionEnabled = YES;
        [_leftBtn set_dcf_textAligment:NSTextAlignmentCenter];
        [_leftBtn set_dcf_textColor:RGBCOLOR(51, 51, 51)];
        [_leftBtn set_dcf_font:[UIFont systemFontOfSize:18.0f]];
        [_leftBtn addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(leftClick)]];
    }
    return _leftBtn;
}

-(void)leftClick{
    [self hide];
    if (_delegate && [_delegate respondsToSelector:@selector(dcfAlertView:withButtonIndex:)]) {
        [_delegate dcfAlertView:self withButtonIndex:0];
    }
}

-(DCFNormalLabel *)rightBtn{
    if (!_rightBtn) {
        _rightBtn = [[DCFNormalLabel alloc] init];
        _rightBtn.userInteractionEnabled = YES;
        [_rightBtn set_dcf_textAligment:NSTextAlignmentCenter];
        [_rightBtn set_dcf_textColor:kMainColor];
        [_rightBtn set_dcf_font:[UIFont systemFontOfSize:18.0f]];
        [_rightBtn addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(rightClick)]];
    }
    return _rightBtn;
}

-(void)rightClick{
    [self hide];
    if (_delegate && [_delegate respondsToSelector:@selector(dcfAlertView:withButtonIndex:)]) {
        [_delegate dcfAlertView:self withButtonIndex:1];
    }
}

-(DCFNormalLabel *)bottomBtn{
    if (!_bottomBtn) {
        _bottomBtn = [[DCFNormalLabel alloc] init];
        _bottomBtn.userInteractionEnabled = YES;
        [_bottomBtn set_dcf_textAligment:NSTextAlignmentCenter];
        [_bottomBtn set_dcf_textColor:kMainColor];
        [_bottomBtn set_dcf_font:[UIFont systemFontOfSize:18.0f]];
        [_bottomBtn addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(bottomClick)]];
    }
    return _bottomBtn;
}

-(void)bottomClick{
    [self hide];
    if (_delegate && [_delegate respondsToSelector:@selector(dcfAlertView:withButtonIndex:)]) {
        [_delegate dcfAlertView:self withButtonIndex:0];
    }
}


@end
